#!/bin/sh

if [ ! -e ./cc-test-reporter ]; then
    if [ `uname` = "Darwin" ]; then
        OS=darwin
    else
        OS=linux
    fi

    curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-${OS}-amd64 > ./cc-test-reporter
    chmod +x ./cc-test-reporter
fi

./cc-test-reporter before-build
npm run test:cover
./cc-test-reporter after-build --coverage-input-type lcov --exit-code $?
